home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / System Extensions / MIDI Management Tools 2.0.2 / Interfaces & Glue / MIDI.a next >
Encoding:
Text File  |  1993-06-10  |  13.3 KB  |  590 lines  |  [TEXT/MPS ]

  1.  
  2. ;;;
  3. ;;; MIDI.a
  4. ;;;
  5. ;;; This file contains the assembly-language interface for the MIDI Manager.
  6. ;;;
  7. ;;; Author: John Worthington, Don Marsh, Mark Lentczner
  8. ;;; Copyright © 1988, Apple Computer, Inc.
  9. ;;; All Rights Reserved
  10. ;;;
  11. ;;; Version 2.0a1
  12.  
  13.  
  14.                 
  15.                 
  16. ;;; ________________________________________________________________________________
  17. ;;;
  18. ;;; Constants:
  19. ;;;
  20.  
  21. midiToolNum            EQU        4        ; tool number of MIDI Mgr for SndDispVersion call.
  22. midiMaxNameLen        EQU        31        ; maximum number of characters in port and client names
  23.  
  24.  
  25. ; Time formats
  26.  
  27. midiFormatMSec        EQU        0        ; milliseconds
  28. midiFormatBeats        EQU        1        ; beats
  29. midiFormat24fpsBit    EQU        2        ; 24 frames/sec.
  30. midiFormat25fpsBit    EQU        3        ; 25 frames/sec.
  31. midiFormat30fpsDBit    EQU        4        ; 30 frames/sec. drop-frame
  32. midiFormat30fpsBit    EQU        5        ; 30 frames/sec.
  33. midiFormat24fpsQF    EQU        6        ; 24 frames/sec. longInt format
  34. midiFormat25fpsQF    EQU        7        ; 25 frames/sec. longInt format
  35. midiFormat30fpsDQF    EQU        8        ; 30 frames/sec. drop-frame longInt format
  36. midiFormat30fpsQF    EQU        9        ; 30 frames/sec. longInt format
  37.  
  38. midiInternalSync    EQU        0        ; internally synced
  39. midiExternalSync    EQU        1        ; externally synced
  40.  
  41.  
  42. ; Port types
  43.  
  44. midiPortTypeTime    EQU        0        ; time port
  45. midiPortTypeInput    EQU        1        ; input port
  46. midiPortTypeOutput    EQU        2        ; output port
  47. midiPortTypeTimeInv    EQU        3        ; invisible time port
  48. midiPortInvisible    EQU        $8000    ; invisible port, add this to the above types.
  49. midiPortTypeMask    EQU        $0007    ; AND with this to convert new port types to old,
  50.                                     ; ie. to mask off the property bits.
  51. ; OffsetTimes
  52.  
  53. midiGetEverything    EQU        $7FFFFFFF    ; get all packets, regardless of time stamps
  54. midiGetNothing        EQU        $80000000    ; get no packets, regardless of time stamps
  55. midiGetCurrent        EQU        $00000000    ; get current packets only
  56.  
  57.  
  58.                 
  59. ;;;
  60. ;;; MIDI data and messages are passed in MIDIPacket records (see below).
  61. ;;; The first byte of every MIDIPacket contains a set of flags
  62. ;;;
  63. ;;; bits 0-1    00 = new MIDIPacket, not continued
  64. ;;;                01 = begining of continued MIDIPacket
  65. ;;;                10 = end of continued MIDIPacket
  66. ;;;                11 = continuation
  67. ;;; bits 2-3    reserved
  68. ;;;
  69. ;;;    bits 4-6    000 = MIDIPacket contains MIDI data
  70. ;;;                001 = MIDIPacket contains MIDI Manager message
  71. ;;;
  72. ;;; bit 7        0 = MIDIPacket has valid stamp
  73. ;;;                1 = stamp with current clock
  74. ;;;
  75.  
  76. midiContMask        EQU        $03
  77. midiNoCont            EQU        $00
  78. midiStartCont        EQU        $01
  79. midiMidCont            EQU        $03
  80. midiEndCont            EQU        $02
  81.  
  82. midiTypeMask        EQU        $70
  83. midiMsgType            EQU        $00
  84. midiMgrType            EQU        $10
  85.  
  86. midiTimeStampMask        EQU        $80
  87. midiTimeStampCurrent    EQU        $80
  88. midiTimeStampValid        EQU        $00
  89.  
  90.  
  91. ; MIDI Manager MIDIPacket command words (the first word in the data field 
  92. ; for midiMgrType messages)
  93.  
  94. midiOverflowErr        EQU        $0001
  95. midiSCCErr            EQU        $0002
  96. midiPacketErr        EQU        $0003
  97. midiMaxErr            EQU        $00FF            ; all command words less than this value
  98.                                             ;   are error indicators
  99.  
  100. ;;; ________________________________________________________________________________
  101. ;;;
  102. ;;; valid results to be returned from readHooks
  103. ;;;
  104.  
  105. midiKeepPacket        EQU        0
  106. midiMorePacket        EQU        1
  107. midiNoMorePacket    EQU        2
  108. midiHoldPacket        EQU        3    
  109.  
  110.  
  111. ;;; ________________________________________________________________________________
  112. ;;;
  113. ;;; Errors:
  114. ;;;
  115.  
  116. midiNoClientErr        EQU        -250    ; no client with that ID found
  117. midiNoPortErr        EQU        -251    ; no port with that ID found
  118. midiTooManyPortsErr    EQU        -252    ; too many ports already installed in the system
  119. midiTooManyConsErr    EQU        -253    ; too many connections made
  120. midiVConnectErr        EQU        -254    ; pending virtual connection created
  121. midiVConnectMade    EQU        -255    ; pending virtual connection resolved
  122. midiVConnectRmvd    EQU        -256    ; pending virtual connection removed
  123. midiNoConErr        EQU        -257    ; no connection exists between specified ports
  124. midiWriteErr        EQU        -258    ; MIDIWritePacket couldn't write to all connected ports
  125. midiNameLenErr        EQU        -259    ; name supplied is longer than 31 characters
  126. midiDupIDErr        EQU        -260    ; duplicate client ID
  127. midiInvalidCmdErr    EQU        -261    ; command not supported for port type
  128.  
  129.  
  130. ;;; _________________________________________________________________________________
  131. ;;;
  132. ;;; Driver calls:
  133. ;;;
  134.  
  135. midiOpenDriver        EQU        1
  136. midiCloseDriver        EQU        2
  137.  
  138.  
  139.                 
  140. ;;; ________________________________________________________________________________
  141. ;;;
  142. ;;; MIDI data and other messages are read and written in packets:
  143. ;;;
  144.  
  145. MIDIPacket        RECORD    0
  146. flags            DS.B    1
  147. len                DS.B    1
  148. tStamp            DS.L    1
  149. data            EQU        *
  150.                 ENDR
  151.  
  152.  
  153. ;;; ________________________________________________________________________________
  154. ;;;
  155. ;;; port information
  156. ;;;
  157.  
  158. MIDIIDRec        RECORD    0
  159. clientID        DS.L    1
  160. portID            DS.L    1
  161.                 ENDR
  162.  
  163. MIDIPortInfo    RECORD    0
  164. type            DS.W    1        ; type of port
  165. timeBase        DS.L    2        ; MIDIIDRec for time base
  166. numConnects        DS.W    1        ; number of connections
  167. cList            EQU        *        ; ARRAY [1..numConnects] of MIDIIDRec 
  168.                 ENDR
  169.  
  170. MIDIPortParams    RECORD    0
  171. portID            DS.L    1        ; ID of port, unique within client
  172. portType        DS.W    1        ; Type of port - input, output, time, etc.
  173. timeBase        DS.W    1        ; refnum of time base, 0 if none
  174. offsetTime        DS.L    1        ; offset for current time stamps
  175. readHook        DS.L    1        ; routine to call when input data is valid
  176. refCon            DS.L    1        ; refcon for port (for client use)
  177. sync            DS.W    1        ; internal, external,other
  178. curTime            DS.L    1        ; current local time for the port
  179. format            DS.W    1        ; time code format in use
  180. name            DS.B    256        ; name of the port. This is a real live string, not a ptr.
  181.  
  182. size            EQU        *        ; size of port params
  183.                 ENDR
  184.  
  185.  
  186. ;;; ________________________________________________________________________________
  187. ;;;
  188. ;;; Clocks:
  189. ;;;
  190.  
  191. MIDIClkInfo        RECORD    0
  192. sync            DS.W    1            ; 0 = internal, 1 = external
  193. curTime            DS.L    1            ; current value of port's clock
  194. format            DS.W    1            ; time code format
  195. size            EQU        *            ; size of MIDIClkInfo
  196.                 ENDR
  197.  
  198. ;;; ________________________________________________________________________________
  199. ;;;
  200. ;;; Equates for MDVR structures
  201. ;;;
  202.  
  203. MDVRInCtlRec     RECORD    0
  204. timeCodeClock    DS.W    1            ; refnum of time base for time code 
  205. timeCodeFormat    DS.W    1            ; format of time code output 
  206. readProc        DS.L    1            ; proc to call with intput characters
  207. commProc        DS.L    1            ; proc to call for handshaking
  208. refCon            DS.L    1            ; refCon passed to readProc, commProc 
  209.                 ENDR
  210.                 
  211.  
  212. MDVROutCtlRec     RECORD    0
  213. timeCodeClock    DS.W    1            ; time base driven by time code 
  214. timeCodeFormat    DS.W    1            ; format of time code to listen to
  215. timeCodeProc    DS.L    1            ; proc called on time code fmt change 
  216. commProc        DS.L    1            ; proc called for handshaking 
  217. refCon            DS.L    1            ; refCon passed to timeCodeProc 
  218. timeCodeFilter    DS.W    1            ; filter time code if true  
  219. midiMsgTicks    DS.L    1            ; value of Ticks when MIDI msg rcvd 
  220. timeCodeTicks    DS.L    1            ; value of Ticks when time code rcvd 
  221.                 ENDR
  222.                 
  223. mdvrAbortNotesOff     EQU 0             ; abort previous mdvrNotesOff request 
  224. mdvrChanNotesOff     EQU 1            ; generate channel note off messages 
  225. mdvrAllNotesOff     EQU 2            ; generate all note off messages
  226.  
  227. mdvrStopOut            EQU 0            ; stop calling MDVROut temporarily
  228. mdvrStartOut        EQU 1            ; resume calling MDVROut
  229.  
  230. ;;; ________________________________________________________________________________
  231. ;;;
  232. ;;; Equates for function selectors
  233. ;;;
  234.  
  235. midiVersion            EQU        0
  236. midiSignIn            EQU        4
  237. midiSignOut            EQU        8
  238. midiGetClients        EQU        12
  239. midiGetClientName    EQU        16
  240. midiSetClientName    EQU        20
  241. midiGetPorts        EQU        24
  242. midiAddPort            EQU        28
  243. midiGetPortInfo        EQU        32
  244. midiConnectData        EQU        36
  245. midiUnConnectData    EQU        40
  246. midiConnectTime        EQU        44
  247. midiUnConnectTime    EQU        48
  248. midiFlush            EQU        52
  249. midiGetReadHook        EQU        56
  250. midiSetReadHook        EQU        60
  251. midiGetPortName        EQU        64
  252. midiSetPortName        EQU        68
  253. midiWakeUp            EQU        72
  254. midiRemovePort        EQU        76
  255. midiGetSync            EQU        80
  256. midiSetSync            EQU        84
  257. midiGetCurTime        EQU        88
  258. midiSetCurTime        EQU        92
  259. midiStartTime        EQU        96
  260. midiStopTime        EQU        100
  261. midiPoll            EQU        104
  262. midiWritePacket        EQU        108
  263. midiWorldChanged    EQU        112
  264. midiGetOffsetTime    EQU        116
  265. midiSetOffsetTime    EQU        120
  266. midiConvertTime        EQU        124
  267. midiGetRefCon        EQU        128
  268. midiSetRefCon        EQU        132
  269. midiGetClRefCon        EQU        136
  270. midiSetClRefCon        EQU        140
  271. midiGetTCFormat        EQU        144
  272. midiSetTCFormat        EQU        148
  273. midiSetRunRate        EQU        152
  274. midiGetClientIcon    EQU        156
  275. midiCallAddress        EQU        164
  276. midiSetConnectionProc    EQU        168
  277. midiGetConnectionProc    EQU        172
  278. midiDiscardPacket        EQU        176
  279. MDVRSignIn            EQU        180
  280. MDVRSignOut            EQU        184
  281. MDVROpen            EQU        188
  282. MDVRClose            EQU        192
  283. MDVRControlIn        EQU        196
  284. MDVRControlOut        EQU        200
  285. MDVRIn                EQU        204
  286. MDVROut                EQU        208
  287. MDVRNotesOff        EQU        212
  288.  
  289. ;;; ________________________________________________________________________________
  290. ;;;
  291. ;;; Call Macros for Assembly
  292. ;;;
  293.  
  294.                 ;;
  295.                 ;; Sound Dispatch trap (if not already defined)
  296.                 ;;
  297.                 IF &TYPE('_SoundDispatch') = 'UNDEFINED' THEN
  298. _SoundDispatch    OPWORD    $A800
  299.                 ENDIF
  300.                 
  301.                 ;;
  302.                 ;; fake _SndDispVersion which calls glue to make sure that the sound
  303.                 ;; dispatcher has been installed
  304.                 ;;
  305.                 MACRO
  306. &label            _SndDispVersion
  307.                 IMPORT    SndDispVersion
  308. &label            JSR        SndDispVersion            ; call the sound dispatcher glue in MIDIGlue.o
  309.                 ENDM
  310.  
  311.  
  312.                 MACRO
  313. &label            _CallMIDIMgr    &selector
  314. &label            MOVE.L    #(&selector<<16)+midiToolNum,D0
  315.                 _SoundDispatch
  316.                 ENDM
  317.  
  318.  
  319.                 MACRO
  320. &label            _MIDISignIn
  321. &label            _CallMIDIMgr    midiSignIn
  322.                 MEND
  323.                 
  324.                 MACRO
  325. &label            _MIDISignOut
  326. &label            _CallMIDIMgr    midiSignOut
  327.                 MEND
  328.  
  329.                 MACRO
  330. &label            _MIDIVersion
  331. &label            _CallMIDIMgr    midiVersion
  332.                 MEND
  333.                 
  334.                 MACRO
  335. &label            _MIDIGetClients
  336. &label            _CallMIDIMgr    midiGetClients
  337.                 MEND
  338.                 
  339.                 MACRO
  340. &label            _MIDIGetClientName
  341. &label            _CallMIDIMgr    midiGetClientName
  342.                 MEND
  343.                 
  344.                 MACRO
  345. &label            _MIDISetClientName
  346. &label            _CallMIDIMgr    midiSetClientName
  347.                 MEND
  348.                 
  349.                 MACRO
  350. &label            _MMGetClientIcon
  351. &label            _CallMIDIMgr    nGetClientIcon
  352.                 MEND
  353.                 
  354.                 MACRO
  355. &label            _MIDIGetPorts
  356. &label            _CallMIDIMgr    midiGetPorts
  357.                 MEND
  358.                 
  359.                 MACRO
  360. &label            _MIDIAddPort
  361. &label            _CallMIDIMgr    midiAddPort
  362.                 MEND
  363.                 
  364.                 MACRO
  365. &label            _MIDIGetPortInfo
  366. &label            _CallMIDIMgr    midiGetPortInfo
  367.                 MEND
  368.                 
  369.                 MACRO
  370. &label            _MIDIConnectData
  371. &label            _CallMIDIMgr    midiConnectData
  372.                 MEND
  373.                 
  374.                 MACRO
  375. &label            _MIDIUnConnectData
  376. &label            _CallMIDIMgr    midiUnConnectData
  377.                 MEND
  378.                 
  379.                 MACRO
  380. &label            _MIDIConnectTime
  381. &label            _CallMIDIMgr    midiConnectTime
  382.                 MEND
  383.                 
  384.                 MACRO
  385. &label            _MIDIUnConnectTime
  386. &label            _CallMIDIMgr    midiUnConnectTime
  387.                 MEND
  388.                 
  389.                 MACRO
  390. &label            _MIDIFlush
  391. &label            _CallMIDIMgr    midiFlush
  392.                 MEND
  393.                 
  394.                 MACRO
  395. &label            _MIDIGetReadHook
  396. &label            _CallMIDIMgr    midiGetReadHook
  397.                 MEND
  398.                 
  399.                 MACRO
  400. &label            _MIDISetReadHook
  401. &label            _CallMIDIMgr    midiSetReadHook
  402.                 MEND
  403.                 
  404.                 MACRO
  405. &label            _MIDIGetPortName
  406. &label            _CallMIDIMgr    midiGetPortName
  407.                 MEND
  408.                 
  409.                 MACRO
  410. &label            _MIDISetPortName
  411. &label            _CallMIDIMgr    midiSetPortName
  412.                 MEND
  413.                 
  414.                 MACRO
  415. &label            _MIDIWakeUp
  416. &label            _CallMIDIMgr    midiWakeUp
  417.                 MEND
  418.                 
  419.                 MACRO
  420. &label            _MIDIRemovePort
  421. &label            _CallMIDIMgr    midiRemovePort
  422.                 MEND
  423.                 
  424.                 MACRO
  425. &label            _MIDIGetSync
  426. &label            _CallMIDIMgr    midiGetSync
  427.                 MEND
  428.                 
  429.                 MACRO
  430. &label            _MIDISetSync
  431. &label            _CallMIDIMgr    midiSetSync
  432.                 MEND
  433.                 
  434.                 MACRO
  435. &label            _MIDIGetCurTime
  436. &label            _CallMIDIMgr    midiGetCurTime
  437.                 MEND
  438.                 
  439.                 MACRO
  440. &label            _MIDISetCurTime
  441. &label            _CallMIDIMgr    midiSetCurTime
  442.                 MEND
  443.                 
  444.                 MACRO
  445. &label            _MIDIStartTime
  446. &label            _CallMIDIMgr    midiStartTime
  447.                 MEND
  448.                 
  449.                 MACRO
  450. &label            _MIDIStopTime
  451. &label            _CallMIDIMgr    midiStopTime
  452.                 MEND
  453.                 
  454.                 MACRO
  455. &label            _MIDIPoll
  456. &label            _CallMIDIMgr    midiPoll
  457.                 MEND
  458.                 
  459.                 MACRO
  460. &label            _MIDIWritePacket
  461. &label            _CallMIDIMgr    midiWritePacket
  462.                 MEND
  463.                 
  464.                 MACRO
  465. &label            _MIDIWorldChanged
  466. &label            _CallMIDIMgr    midiWorldChanged
  467.                 MEND
  468.                 
  469.                 MACRO
  470. &label            _MIDIGetOffsetTime
  471. &label            _CallMIDIMgr    midiGetOffsetTime
  472.                 MEND
  473.                 
  474.                 MACRO
  475. &label            _MIDISetOffsetTime
  476. &label            _CallMIDIMgr    midiSetOffsetTime
  477.                 MEND
  478.                 
  479.                 MACRO
  480. &label            _MIDIConvertTime
  481. &label            _CallMIDIMgr    midiConvertTime
  482.                 MEND
  483.                 
  484.                 MACRO
  485. &label            _MIDIGetRefCon
  486. &label            _CallMIDIMgr    midiGetRefCon
  487.                 MEND
  488.                 
  489.                 MACRO
  490. &label            _MIDISetRefCon
  491. &label            _CallMIDIMgr    midiSetRefCon
  492.                 MEND
  493.                 
  494.                 MACRO
  495. &label            _MIDIGetClRefCon        
  496. &label            _CallMIDIMgr    midiGetClRefCon
  497.                 MEND
  498.                 
  499.                 MACRO
  500. &label            _MIDISetClRefCon    
  501. &label            _CallMIDIMgr    midiSetClRefCon
  502.                 MEND
  503.  
  504.                 MACRO
  505. &label            _MIDIGetTCFormat        
  506. &label            _CallMIDIMgr    midiGetTCFormat
  507.                 MEND
  508.                 
  509.                 MACRO
  510. &label            _MIDISetTCFormat    
  511. &label            _CallMIDIMgr    midiSetTCFormat
  512.                 MEND
  513.                 
  514.                 MACRO
  515. &label            _MIDISetRunRate
  516. &label            _CallMIDIMgr    midiSetRunRate
  517.                 MEND
  518.                 
  519.                 MACRO
  520. &label            _MIDIGetClientIcon
  521. &label            _CallMIDIMgr    midiGetClientIcon
  522.                 MEND
  523.                 
  524.                 
  525.                 MACRO
  526. &label            _MIDICallAddress
  527. &label            _CallMIDIMgr    midiCallAddress
  528.                 MEND
  529.  
  530.                 MACRO
  531. &label            _MIDISetConnectionProc
  532. &label            _CallMIDIMgr    midiSetConnectionProc
  533.                 MEND
  534.                 
  535.                 MACRO
  536. &label            _MIDIGetConnectionProc
  537. &label            _CallMIDIMgr    midiGetConnectionProc
  538.                 MEND
  539.                 
  540.                 MACRO
  541. &label            _MIDIDiscardPacket
  542. &label            _CallMIDIMgr    midiDiscardPacket
  543.                 MEND
  544.                 
  545.                 MACRO
  546. &label            _MDVRSignIn        
  547. &label            _CallMIDIMgr    MDVRSignIn
  548.                 MEND
  549.                 
  550.                 MACRO
  551. &label            _MDVRSignOut
  552. &label            _CallMIDIMgr    MDVRSignOut
  553.                 MEND
  554.                 
  555.                 MACRO
  556. &label            _MDVROpen
  557. &label            _CallMIDIMgr    MDVROpen
  558.                 MEND
  559.                 
  560.                 MACRO
  561. &label            _MDVRClose
  562. &label            _CallMIDIMgr    MDVRClose
  563.                 MEND
  564.                 
  565.                 MACRO
  566. &label            _MDVRControlIn    
  567. &label            _CallMIDIMgr    MDVRControlIn
  568.                 MEND
  569.                 
  570.                 MACRO
  571. &label            _MDVRControlOut
  572. &label            _CallMIDIMgr    MDVRControlOut
  573.                 MEND
  574.                 
  575.                 MACRO
  576. &label            _MDVRIn
  577. &label            _CallMIDIMgr    MDVRIn
  578.                 MEND
  579.                 
  580.                 MACRO
  581. &label            _MDVROut
  582. &label            _CallMIDIMgr    MDVROut
  583.                 MEND
  584.                 
  585.                 MACRO
  586. &label            _MDVRNotesOff    
  587. &label            _CallMIDIMgr    MDVRNotesOff
  588.                 MEND
  589.  
  590.